package edu.stanford.bmir.protege.web.server.stkosutil.cutter;

import edu.stanford.bmir.protege.web.client.rpc.stkosutil.cutter.CuttingOptions;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.cutter.CuttingResult;
import edu.stanford.bmir.protege.web.client.rpc.stkosutil.cutter.CuttingScope;
import edu.stanford.bmir.protege.web.shared.user.UserId;

public class OntologyCutter {
 	public CuttingResult cutOntology(String projectName, CuttingOptions options, UserId userId){
 		CuttingResult result = null;
 		if (options.getCuttingScope()==CuttingScope.ALL_CLASSES || options.getCuttingScope()==CuttingScope.SELECTED_CLASS_TREE){
 			ClassCutter cutter = new ClassCutter();
 			result = cutter.cutOntology(projectName, options, userId);
 		}else if (options.getCuttingScope()==CuttingScope.ALL_PROPERTIES || options.getCuttingScope()==CuttingScope.SELECTED_PROPERTY_TREE){
 			ObjectPropertyCutter objectPropertyCutter = new ObjectPropertyCutter();
 			result = objectPropertyCutter.cutOntology(projectName, options, userId);
 			DataPropertyCutter dataPropertyCutter = new DataPropertyCutter();
 			CuttingResult resultOfDataProperty = dataPropertyCutter.cutOntology(projectName, options, userId);
 			result.setCutDataPropertyNumber(resultOfDataProperty.getCutDataPropertyNumber());
 			result.setTotalDataPropertyNumber(resultOfDataProperty.getTotalDataPropertyNumber());
 			result.setCutPropertyNumber(result.getCutDataPropertyNumber() + result.getCutObjectPropertyNumber());
 			result.setTotalPropertyNumber(result.getTotalDataPropertyNumber() + result.getTotalObjectPropertyNumber());
 		}else if (options.getCuttingScope()==CuttingScope.ALL_INDIVIDUALS){
 			IndividualCutter cutter = new IndividualCutter(); 
 			result = cutter.cutOntology(projectName, options, userId);
 		} 	
 		return result;
 	}
}
